
<title>Shipping Carriers</title>


<?php  

/*

***************************************
*                                     *
* Copyright 2011 David Matthew Pugh   *
* Contact Info:thebravedave@gmail.com *
*                                     *
***************************************

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/
  
require_once "../services/webservices.php";
require_once "index.php";
require_once("../Pagination.php");
  
  
   
?>



<script type="text/javascript">
    function checkform()
    {     
        var go = confirm("Deleting a carrier deletes all associated services.  Are you sure you wish to proceed?");
        return go;
        
       
    }
</script> 

<?php

echo '<br /><br /><br /><br /> ';


if(isset($_POST['carriers']))
{
    $carrier = $_POST['carriers'];
    
    $shipping = new shipping();
    $shipping->carrier_name = $carrier;
    $carrierReturn = $shipping->getshippingcarrierbycarriername();
    $carrierXml = new SimpleXMLElement($carrierReturn);
    $carrierCount = $carrierXml->Item_Count;
    if($carrierCount == 0)
    {
       $shipping->addshippingcarrier();  
        
    }
    else
    {
        echo '<b>Carrier Already Exists In Database</b><br /><br />';
    }
} 
if(isset($_POST['deletecarrier']))
{
    $carrier = $_POST['currentcarrier'];
    
    $shipping = new shipping();
    $shipping->carrier_name = $carrier;
    $carrierReturn = $shipping->deletecarrierbycarriername();
    
   
} 


?>


<div class="smallcorerightmargin">
<b>Currently Available Carriers</b><br />
<form action="./shippingcarriers.php" method="POST">
    <select name="carriers" >
        <option value="UPS">UPS</option>
        <option value="USPS">USPS</option>
    </select>
    <input type="submit" name="submitcarrier" value="Add Carrier"/>
</form>
<br /><br />
</div>
<?php
$shipping = new shipping(); 
$carrierReturn = $shipping->getshippingcarriers();
$carrierXml = new SimpleXMLElement($carrierReturn);
$carrierCount = $carrierXml->Item_Count;
if($carrierCount > 0)
{
    echo '<div class="smallcorerightmargin">';
    echo '<b>Carriers Currently In Use</b><br />'; 
    echo '<form action="./shippingcarriers.php" method="POST">';
    echo '<b>Carrier Name:</b><select name="currentcarrier">';
    foreach($carrierXml->Item as $carrierItem)
    {
        $carrier_name = $carrierItem->carrier_name;
        echo "<option value='$carrier_name'>$carrier_name</option>";
    }
    echo '</select><br />';
    ?>
    <input type="submit" id="deletecarrier" name="deletecarrier" value="delete carrier" onclick="javascript: return checkform();"/> 
    <?php
    echo '</form>';   
}
echo '</div>';    



    
   
    
    
?>